/****************************************************************
 * <strong>MFDataNode数据节点</strong>
 * <p>
 * 数据节点
 * </p>
 *
 * @author AndyZhang 2011
 * @version 0.1
 * ToDo:
 ***************************************************************/

package com.thinkwide.data.vdata;

public class MFDataNode {
    private String id;
    private String text;
    //private int level;
    //private int levelIndex;
    private Object data;
    private MFDataNode parent = null;
    private MFDataNodes childs;
    private String state;
    private String tag;
    private int left;
    private int top;
    private int width = 170;
    private int height = 180;
    private int leafHeight = 0;

    public MFDataNode() {
        childs = new MFDataNodes();
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

    public int getIndex() {
        int i = 0;
        if (getParent() != null) {
            i = getParent().getChilds().indexOf(this);
        }
        return i;
    }

    public void setParent(MFDataNode parent) {
        this.parent = parent;
    }

    public MFDataNode getParent() {
        return parent;
    }

    public MFDataNodes getChilds() {
        return childs;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public void delete() {

    }

    public MFDataNode getPrevNode() {
        if (this.getParent() != null) {
            MFDataNode node = this.getParent();
            int i = node.getChilds().indexOf(this);
            if (i > 0)
                return node.getChilds().get(i - 1);
            else
                return null;
        }

        return null;
    }

    public MFDataNode getNextNode() {
        if (this.getParent() != null) {
            MFDataNode node = this.getParent();
            int i = node.getChilds().indexOf(this);
            if (i == (node.getChilds().size() - 1))
                return null;
            else
                return node.getChilds().get(i + 1);
        }

        return null;
    }

    public int getLevel() {
        MFDataNode parentNode = getParent();
        int i = 0;
        while (parentNode != null) {
            parentNode = parentNode.getParent();
            i = i + 1;
        }
        return i;
    }

    public int getLevelIndex() {
        int i = 0;
        if (getParent() != null) {
            i = getParent().getChilds().indexOf(this);

        }
        return i;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getState() {
        return state;
    }

    public void setLeft(int left) {
        this.left = left;
    }

    public int getLeft() {
        return left;
    }

    public void setTop(int top) {
        this.top = top;
    }

    public int getTop() {
        return top;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getWidth() {
        return width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getHeight() {
        return height;
    }

    public void setLeafHeight(int leafHeight) {
        this.leafHeight = leafHeight;
    }

    public int getLeafHeight() {
        return leafHeight;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public String getTag() {
        return tag;
    }
}
